﻿#pragma once
#include "yzrutil.h"
#include "soundbank/ModelByteBuffer.h"
#include "soundbank/SoundbankResource.h"

namespace yzrilyzr_soundbank{
	class SF2Soundbank;
	ECLASS(SF2Sample, public SoundbankResource){
		int64_t startLoop=0;
		int64_t endLoop=0;
		int64_t sampleRate=44100;
		int32_t originalPitch=60;
		int8_t pitchCorrection=0;
		int32_t sampleLink=0;
		int32_t sampleType=0;
		std::shared_ptr<ModelByteBuffer> data;
		std::shared_ptr<ModelByteBuffer> data24;
		public:
		SF2Sample(SF2Soundbank * soundBank);
		SF2Sample();
		ModelByteBuffer * getDataBuffer(){
			return data.get();
		}
		ModelByteBuffer * getData24Buffer(){
			return data24.get();
		}
		void setData(std::shared_ptr<yzrilyzr_array::ByteArray> data, u_index offset, u_index length){
			this->data=std::make_shared<ModelByteBuffer>(data, offset, length);
		}
		void setData24(std::shared_ptr<ModelByteBuffer> data24){
			this->data24=data24;
		}
		void setData24(std::shared_ptr<yzrilyzr_array::ByteArray> data24){
			this->data24=std::make_shared<ModelByteBuffer>(data24);
		}
		void setData24(std::shared_ptr<yzrilyzr_array::ByteArray> data24, u_index offset, u_index length){
			this->data24=std::make_shared<ModelByteBuffer>(data24, offset, length);
		}
		/*
		void setData(File file, u_index offset, u_index length) {
			this->data = nullptr;
			this->sampleFile = file;
			this->sampleOffset = offset;
			this->sampleLen = length;
		}
		*/
		yzrilyzr_lang::String getName()const override{
			return name;
		}
		void setName(const yzrilyzr_lang::String & name){
			this->name=name;
		}
		void setData(std::shared_ptr<ModelByteBuffer> data){
			this->data=data;
		}
		void setData(std::shared_ptr<yzrilyzr_array::ByteArray> data){
			this->data=std::make_shared<ModelByteBuffer>(data);
		}
		int64_t getEndLoop(){
			return endLoop;
		}
		void setEndLoop(int64_t endLoop){
			this->endLoop=endLoop;
		}
		int32_t getOriginalPitch(){
			return originalPitch;
		}
		void setOriginalPitch(int32_t originalPitch){
			this->originalPitch=originalPitch;
		}
		int8_t getPitchCorrection(){
			return pitchCorrection;
		}
		void setPitchCorrection(int8_t pitchCorrection){
			this->pitchCorrection=pitchCorrection;
		}
		int32_t getSampleLink(){
			return sampleLink;
		}
		void setSampleLink(int32_t sampleLink){
			this->sampleLink=sampleLink;
		}
		int64_t getSampleRate(){
			return sampleRate;
		}
		void setSampleRate(int64_t sampleRate){
			this->sampleRate=sampleRate;
		}
		int32_t getSampleType(){
			return sampleType;
		}
		void setSampleType(int32_t sampleType){
			this->sampleType=sampleType;
		}
		int64_t getStartLoop(){
			return startLoop;
		}
		void setStartLoop(int64_t startLoop){
			this->startLoop=startLoop;
		}
		yzrilyzr_lang::String toString() const override{
			return "SampleData: " + name;
		}
	};
}
